Skip to content

feat(nip42): add session tracking and optional authRequired - #716

Open
Anshumancanrock wants to merge 5 commits into
cameri:mainfrom
Anshumancanrock:feat/nip42-session
Open

feat(nip42): add session tracking and optional authRequired#716
Anshumancanrock wants to merge 5 commits into
cameri:mainfrom
Anshumancanrock:feat/nip42-session

Conversation

@Anshumancanrock

Copy link
Copy Markdown
Collaborator

Summary

This PR tightens NIP-42 session handling without changing default relay behavior.

  • Track authenticated pubkeys in a proper per-socket session (with optional sessionTtl)
  • Add nip42.authRequired so relays can require AUTH before publishes
  • Advertise that correctly in NIP-11 (limitation.auth_required)

Defaults stay off (authRequired: false, sessionTtl: 0), so existing open relays behave the same.

@changeset-bot

changeset-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: dcf8f6b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
nostream Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coveralls

coveralls commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 69.873% (-0.3%) from 70.185% — Anshumancanrock:feat/nip42-session into cameri:main

@Anshumancanrock
Anshumancanrock requested a review from cameri August 5, 2026 07:10
@cameri
cameri requested a balanced review from Copilot August 12, 2026 02:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds per-socket NIP-42 session tracking, optional session expiry, and configurable publish authentication.

Changes:

  • Introduces Nip42SessionManager with TTL support.
  • Enforces optional authentication for event publishing.
  • Updates NIP-11 metadata, configuration, documentation, and tests.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
.changeset/nip42-session-manager.md Records the minor feature release.
CONFIGURATION.md Documents the new NIP-42 settings.
resources/default-settings.yaml Adds disabled-by-default configuration.
src/@types/settings.ts Types the new settings.
src/adapters/web-socket-adapter.ts Integrates per-socket sessions and expiry.
src/handlers/event-message-handler.ts Enforces publish authentication.
src/handlers/request-handlers/root-request-handler.ts Advertises authentication in NIP-11.
src/routes/index.ts Adds CodeQL annotations for public routes.
src/utils/nip42-session.ts Implements session and challenge management.
src/utils/nip42.ts Adds the authentication-setting helper.
test/unit/adapters/web-socket-adapter.spec.ts Tests adapter session behavior.
test/unit/handlers/event-message-handler.spec.ts Tests publish-auth decisions.
test/unit/handlers/request-handlers/root-request-handler.spec.ts Tests NIP-11 metadata.
test/unit/utils/nip42-session.spec.ts Tests session management and expiry.
test/unit/utils/nip42.spec.ts Tests authentication configuration.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/handlers/request-handlers/root-request-handler.ts Outdated
Comment thread test/unit/adapters/web-socket-adapter.spec.ts Outdated
Comment thread src/adapters/web-socket-adapter.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants